<template>
	<div class="login">
		<form>
			用户名: 	<input type="text"  v-model="username"/>
			密码: <input type="password" v-model="psw"/>
			<input type="submit"  value="登录" @click.prevent="sub" />
		</form>
	</div>
</template>

<script>
	import axios from "axios";
	export default{
		data(){
			return{
				username:"",
				psw:""
			}
		},
		methods:{
			sub(){
				console.log(this.username)
				console.log(this.psw)
				axios.post("/login",{
					"username":this.username,
					"psw":this.psw
				}).then((res)=>{
					if(res.data.msg=="0"){
						alert("账户密码输入有误")
					}else{
						alert("验证成功")
						setTimeout(()=>{
							//路由的跳转
							this.$router.push({
								path:this.$route.query.redirect
							},1000)
						})
					}
				}).catch((e)=>{
					console.log(e)
				})
			}
		}
	}
</script>

<style lang="scss">
	.login{
		position: absolute;
		top: 100px;
	}
</style>